home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!smryan
- From: smryan@netcom.com (@#$%!?!)
- Subject: Re: Beginner need help??????????????
- Message-ID: <smryanDpMrH3.Ct5@netcom.com>
- Organization: The Programmer formerly known as S M Ryan
- X-Newsreader: TIN [version 1.2 PL1]
- References: <4kem82$5j3@dewey.csun.edu>
- Date: Wed, 10 Apr 1996 05:05:27 GMT
- Sender: smryan@netcom12.netcom.com
-
- : -------- program 1 -------------------------
-
- : answer = 1 / 3;
-
- If both operand of a division are integers, as is in this case, integer
- truncation division is used. In this case 1/3 truncated is indeed 0.
- C does not have distinguish integer division operator. Nor does it
- consider the eventual destination type. It will _not_ say, oh, this will
- be a float, so let's make it one from the beginning.
-
- You can override the division operator in C++.
-
- : ----------program 2----------------------------
- : #include <stdio.h>
-
- : float result;
-
- : printf("The result is %d\n", result);
-
- C does not make the actual types of a variable list of arguments available
- to the caller, and so the caller must guess the types. If the format
- descriptor is %...d, printf assumes it is an int value. On almost any
- machine the ints and floats will be encoded differently. You have to use
- floating point descriptor such as %f, %g, or %e.
-
- : ----------program 3---------------------------
-
- : int integer;
- : printf("The value of integer is %f\n", integer);
-
- The same, the other way around.
-
- --
- The Queen, amused, in quiet power, | smryan@netcom.com PO Box 1563
- will draw the son to darkenned bower. | Cupertino, California
- Her face is fair, her fragrance rare, | (xxx)xxx-xxxx 95015
- with woven webs for wayward flower. | I don't use no smileys
-